package ingsw2.ii.dp.reader;

import java.util.HashMap;
import java.util.Map;

public abstract class MyStatistic {
	
	protected Map<Character,Integer> map = new HashMap<Character,Integer>();
	
	protected void statistic(String value) {
		for(int i=0; i<value.length(); i++){
			if (map.get(value.charAt(i)) == null)
				map.put(value.charAt(i), 1);
			else
				map.put(value.charAt(i), map.get(value.charAt(i))+1);
		}
	}
	
	public void printStatistic(MyPrint print){
		print.write("\nSTATISTICS: ");
		for (Map.Entry<Character, Integer> entry : map.entrySet()) {
			print.write(entry.getKey() + " " + entry.getValue());
		}
	}
}
